Developer --> Technical Publications
PATHHardware Documentation > USB Devices > Mac OS USB DDK API Reference


USBDeallocMem

The USBDeallocMem function deallocates the memory allocated with the USBAllocMem function.

OSStatus USBDeallocMem(USBPB *pb);

Required fields in the USBPB parameter block for the USBDeallocMem function are:

--> pbLength
Length of parameter block
--> pbVersion
Parameter block version number
--> usbCompletion
The completion routine
--> usbRefcon
General-purpose value passed back to the completion routine
--> usbReference
A device, interface, or pipe reference which associates the call with a device

<--> usbBuffer
--> previously allocated memory to be deallocated
<-- pointer set to nil
--> usbFlags
Should be set to 0

You can pass kUSBNoCallBack as the usbCompletion field parameter to notify the USL that you want the operation to complete immediately if at task time. It is an error to specify no call back, if the current execution level is not task time.

If the usbCompletion field is set to kUSBNoCallBack , the call back mechanism is not invoked, and the specified usbReference is not checked or used. This is useful for finalization routines which need to clean up immediately and can't wait for a callback routine to complete.

There must be a valid USBReference passed in the usbReference field of the parameter block. If a reference that does not match an existing device, interface, or pipe is passed in, the call returns immediately with an unknown device error.

If the device associated with this call is unplugged and its driver removed while this function call is pending, the function will not complete. In this case, your finalize routine can assume that it is safe to dispose of the parameter block for this call.

The USBDeAllocMem function returns the following error:

kUSBUnknownDeviceErr
-6998 usbReference does not refer to a current device
kUSBCompletionError
-6984 kUSBNoCallBack was specified and current execution level is not task time

© 1999 Apple Computer, Inc.

Previous | Back Up One Level | Next | Show Frames | Hide Frames